home *** CD-ROM | disk | FTP | other *** search
/ The Fatted Calf / The Fatted Calf.iso / Applications / Workspace / TickleServices / Documentation / E.Aux / unhide.m < prev    next >
Encoding:
Text File  |  1994-03-22  |  1.2 KB  |  56 lines

  1. /* unhide.m -- tell an application to unhide itself */
  2. /* This application was written by eps@futon.SFSU.EDU (Eric P. Scott)
  3.  * and posted to the net.
  4.  *
  5.  * This is a good example of why TickleServices needs loadable Tcl
  6.  * built-ins.
  7.  */
  8.  
  9. /* cc -o unhide -s -O unhide.m -lNeXT_s */
  10. /* cc -arch m68k -arch i386 -o unhide -s -O unhide.m -lNeXT_s */
  11.  
  12. #ifdef NX_COMPILER_RELEASE_3_0
  13. #include <bsd/libc.h>
  14. #include <mach/mach.h>
  15. #else
  16. #include <libc.h>
  17. #include <mach.h>
  18. #endif
  19. #import <appkit/Listener.h>
  20. #import <appkit/Speaker.h>
  21.  
  22. main(int argc, char *argv[])
  23. {
  24.     register int i;
  25.     char *a;
  26.     port_t p;
  27.     int e;
  28.     id spkr;
  29.  
  30.     if (argc<2) {
  31.     (void)fprintf(stderr, "Usage: %s application [...]\n", *argv);
  32.     exit(1);
  33.     }
  34.     e=0;
  35.     spkr=nil;
  36.     for (i=1;i<argc;i++) {
  37.     a=argv[i];
  38.     if (!strcmp(a, "Workspace")) {
  39.         register char *w;
  40.         if (w=getenv("Workspace")) a=w;
  41.     }
  42.     if (p=NXPortNameLookup(a, (char *)NULL)) {
  43.         if (!spkr) spkr=[[Speaker alloc] init];
  44.         [spkr setSendPort:p];
  45.         if ([spkr performRemoteMethod:"unhide"]) e++;
  46.         (void)port_deallocate(task_self(), p);
  47.     }
  48.     else {
  49.         (void)fprintf(stderr, "%s: \"%s\" not running\n", *argv, argv[i]);
  50.         e++;
  51.     }
  52.     }
  53.     if (spkr) [spkr free];
  54.     exit(e);
  55. }
  56.